home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #1 / Amiga Plus 1999 #1.iso / System-Boost / Workbench / BackClock / sources / main.c < prev    next >
C/C++ Source or Header  |  1998-08-10  |  3KB  |  99 lines

  1. /*****************************************************************************
  2.  *
  3.  * Nom            : main.c
  4.  *
  5.  * version        : $VER: main.c 1.2 (11.04.98)
  6.  *
  7.  * History
  8.  * V1.0: initial version
  9.  * V1.1: can be started from WB with Tooltypes
  10.  *       added notifyintuition routines to close the window automatically
  11.  * v1.2: window can initialy sized thanks to tooltypes
  12.  *       window goes to back every seconds
  13.  *       first public release
  14.  * v1.3: close|open workbench now works
  15.  *       changed clock style
  16.  * v2.0: Totally customizable via a GUI
  17.  * v2.1: Transparent. Removed some unused code 
  18.  *
  19.  * future: customizable clock style
  20.  *****************************************************************************
  21.  */
  22. #include <intuition/intuition.h>
  23. #include <dos/dos.h>
  24. #include <exec/ports.h>
  25. #include <exec/libraries.h>
  26. #include <exec/memory.h>
  27. #include <workbench/startup.h>
  28.  
  29. #include <proto/intuition.h>
  30. #include <proto/exec.h>
  31. #include <proto/dos.h>
  32. #include "utils.h"
  33. /* bump revision
  34.  */
  35. char  * nosense = "\0$VER: " TITLE " (06.08.98)" ;
  36.  
  37. void main() {
  38.   /* lance du CLI
  39.    */
  40.   idWin * myprj ;
  41.   if (exists() == FALSE) {
  42.     Delay(50) ;
  43.     if ((myprj = init(NULL)) != NULL) {
  44.       //writeDate(myprj) ;
  45.       processwin(myprj) ;
  46.       close(myprj) ;
  47.     }
  48.     
  49.   }
  50.  
  51. }
  52. void wbmain() {
  53.   /* lance du WB
  54.    */
  55.   void main() ;
  56.   main() ;  
  57. }
  58. int exists() {
  59.   int ret = FALSE ;
  60.   struct EasyStruct EZ ;
  61.   struct MsgPort * oldPort ;
  62.   struct MsgPort * replyPort ; 
  63.   struct backMsg * msg ;
  64.  
  65.   Forbid() ;
  66.   oldPort = FindPort("backclock") ;
  67.   Permit() ;
  68.   
  69.   if (oldPort) {
  70.     /* le programme est deja lance
  71.      */
  72.     EZ.es_StructSize   = sizeof(struct EasyStruct) ;
  73.     EZ.es_Flags        = NULL ;
  74.     EZ.es_Title        = TITLE ;
  75.     EZ.es_TextFormat   = "You are about to quit BackClock\nAre you sure ?" ;
  76.     EZ.es_GadgetFormat = "Quit|Cancel" ;
  77.     if (EasyRequestArgs(NULL, &EZ, NULL, NULL) == 1) {
  78.       /* utilisateur choisit quit
  79.        */  
  80.       if ((replyPort = CreateMsgPort()) != NULL) {
  81.         if ((msg = AllocVec(sizeof(struct backMsg), MEMF_PUBLIC)) != NULL) {
  82.           msg->execmsg.mn_Node.ln_Type = NT_MESSAGE ;
  83.           msg->execmsg.mn_Length       = sizeof(struct backMsg) ;
  84.           msg->execmsg.mn_ReplyPort    = replyPort ;
  85.           msg->Class = BC_Quit ;  // stop !!!
  86.           PutMsg(oldPort, (struct Message*)msg) ;
  87.           WaitPort(replyPort) ;
  88.           DeleteMsgPort(replyPort) ;
  89.           FreeVec(msg) ;
  90.           ret=OK ;
  91.         }else {
  92.           ret=ERRORNOMEM ;
  93.           DeleteMsgPort(replyPort) ;
  94.         }
  95.       }else ret=ERRORNOMEM ;
  96.     }else ret = OK ;
  97.   }
  98.   return(ret) ;
  99. }